package com.lizhe.config.config;

import com.lizhe.config.model.Child;
import com.lizhe.config.model.Father;
import com.lizhe.config.model.Mother;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;


/**
 * 类描述: 读取 application.yml 配置
 * 成员变量名称要和yml配置项key一一对应
 *
 * @author Administrator
 * @create 2021-10-21 22:50
 */

@Data
@Component
@Validated // 在需要校验的属性装配类上加@Validated注解
@ConfigurationProperties(prefix = "family")
public class FamilyProperties {
    // 校验familyName，必须不能为空 如果为空服务会启动失败
    // 还有Min Max 等校验注解
    // @Min(10)
    @NotEmpty
    private String familyName;
    private Father father;
    private Mother mother;
    private Child child;
}